/**
This file is part of dbdjasperreport.

Copyright (C) 2008 Kue Vang aka Kou
Licensed under the Eclipse Public License, Version 1.0; 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at http://www.eclipse.org/legal/epl-v10.html 
Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and limitations 
under the License.
**/

class UtilTagLib {
	def dateFormat = { attrs ->
		out << new java.text.SimpleDateFormat(attrs.format)
                           .format(attrs.value)
	}
	
	def emptyReportList={attrs->
		out << render(template:"/templates/common/emptyReportListTemplate")
	}
	
	def emptyParamList={attrs->
		out << render(template:"/templates/common/emptyParamListTemplate")
	}
	
	def helpHome = {
		out << render(template:"/templates/common/helpHomeTemplate",
						model:[])
	}
	
	def userGuideLink = {
		out << render(template:"/templates/common/userGuideLinkTemplate",
						model:[])
	}
	
	def dateInputFormat = {
		out << "Format: 'MM/DD/YYYY'"
	}	
	
	def displayDataType = {attrs ->
	    def dataTypeService = new DataTypeService()
		out << dataTypeService.getDataTypeDesc(attrs.value)		
	}

	def displayOperator = {attrs ->
		def operatorService = new OperatorService()
		out << operatorService.getOperatorDesc(attrs.value)
	}
	
	def reportList = {attrs->
		out << render(template:"/templates/common/reportListTemplate",
		              model:[reportList:attrs.value])
	}
	
	def paramList = {attrs->
		out << render(template:"/templates/common/parameterListTemplate",
					  model:[parameterList:attrs.value] )
	}
	
	def operatorOption = { attrs ->
		out << render(template:"/templates/common/operatorOptionTemplate",
						model:[operatorOptions:attrs.operatorOptions,
						       idOperatorSelected:attrs.idOperatorSelected])
	}
	
	
	def entityHeading = { attrs ->
		out << render(template:"/templates/common/entityHeadingTemplate",
						model:[value:attrs.value])
	}
	
	def otherEntryHeading = { attrs ->
		out << render(template:"/templates/common/otherEntryHeadingTemplate",
						model:[value:attrs.value])
	}
	
	def dateEntryScreen = {attrs->
		def operatorService = new OperatorService()
		def dateOperatorList = operatorService.loadDateOperator()
		out << render(template:"/templates/common/dateEntryScreenTemplate",
					model:[rptParam:attrs.rptParam, dateOperatorList:dateOperatorList,
						    showDateDiv4:attrs.showDateDiv4, showDateDiv5:attrs.showDateDiv5, 
						    showDateDiv6:attrs.showDateDiv6, showDateDiv7:attrs.showDateDiv7,
							showDateDiv8:attrs.showDateDiv8, showDateDiv9:attrs.showDateDiv9,
							dateBetween1Str:attrs.dateBetween1Str, dateBetween2Str:attrs.dateBetween2Str,
							dateGreaterEqualStr:attrs.dateGreaterEqualStr, dateLessEqualStr:attrs.dateLessEqualStr,
							dateEqualStr:attrs.dateEqualStr])	
	}
	
	def numberEntryScreen ={attrs->
		def operatorService = new OperatorService()
		def numOperatorList = operatorService.loadNumberOperator()
		out << render(template:"/templates/common/numberEntryScreenTemplate",
					model:[rptParam:attrs.rptParam, showNumDiv5:attrs.showNumDiv5,
						    showNumDiv1:attrs.showNumDiv1, showNumDiv2:attrs.showNumDiv2,
							showNumDiv3:attrs.showNumDiv3, showNumDiv4:attrs.showNumDiv4,
							numOperatorList:numOperatorList])
	
	}
	
	def stringEntryScreen={attrs->
		def operatorService = new OperatorService()
		def strOperatorList = operatorService.loadStringOperator()
		out << render(template:"/templates/common/stringEntryScreenTemplate",
						model:[rptParam:attrs.rptParam, strOperatorList:strOperatorList])	
	}
	
	def codeEntryScreen={attrs->
		out << render(template:"/templates/common/codeEntryScreenTemplate",
						model:[codeSourceList:attrs.codeSourceList,
							   codeSelectedList:attrs.codeSelectedList,
							   rptParam:attrs.rptParam, addOne:attrs.addOne, minusOne:attrs.minusOne,
							   addAll:attrs.addAll, minusAll:attrs.minusAll])
	}
	
	def entityEntryScreen={attrs->
		def operatorService = new OperatorService()
		def strOperatorList = operatorService.loadStringOperator()
		out << render(template:"/templates/common/entityEntryScreenTemplate",
						model:[codeSourceList:attrs.codeSourceList,strOperatorList:strOperatorList,
							   codeSelectedList:attrs.codeSelectedList,
							   rptParam:attrs.rptParam, addOne:attrs.addOne, minusOne:attrs.minusOne,
							   addAll:attrs.addAll, minusAll:attrs.minusAll])
	}
	
	def booleanEntryScreen={attrs->
	    def operatorService = new OperatorService()
		def booleanOperatorList = operatorService.loadBooleanOperator()
		out << render(template:"/templates/common/booleanEntryScreenTemplate",
						model:[rptParam:attrs.rptParam, booleanOperatorList:booleanOperatorList])
	}
	
	def yesNoEntryScreen={attrs->
		def operatorService = new OperatorService()
		def yesNoOperatorList = operatorService.loadYesNoOperator()
		out << render(template:"/templates/common/yesNoEntryScreenTemplate",
						model:[rptParam:attrs.rptParam, yesNoOperatorList:yesNoOperatorList])
	}
	
	def errorMsg={attrs ->
		out << render(template:"/templates/common/errorMsgTemplate",
		               model:[message:attrs.message])
	}
	
}
